package com.hzlj.position.locate.converter;

import com.hzlj.position.locate.common.dto.abnProhibitAreas.AbnProhibitAreasAddDTO;
import com.hzlj.position.locate.common.dto.abnProhibitAreas.AbnProhibitAreasQueryResultDTO;
import com.hzlj.position.locate.common.dto.abnProhibitAreas.AbnProhibitAreasUpdateDTO;
import com.hzlj.position.locate.common.model.AbnProhibitAreas;
import com.fz.common.base.converter.ModelDTOConverter;
import com.fz.common.base.core.date.DateUtils;

/**
 * 禁止区域(AbnProhibitAreas)DTO转换类
 *
 * @author lifh
 * @date 2023-03-28 10:20:32
 */
public class AbnProhibitAreasConverter {
    /**
     * model实例转换为查询结果DTO
     *
     * @param model model实例
     * @return DTO
     */
    public static AbnProhibitAreasQueryResultDTO from(AbnProhibitAreas model) {
        return ModelDTOConverter.from(model, AbnProhibitAreasQueryResultDTO.class);
    }

    /**
     * 新增DTO转换为model实例
     *
     * @param dto 新增DTO
     * @return model实例
     */
    public static AbnProhibitAreas from(AbnProhibitAreasAddDTO dto) {
        return ModelDTOConverter.from(dto, AbnProhibitAreas.class, (AbnProhibitAreas l) -> {
            l.setValid(true);
            l.setUpdateTime(DateUtils.now());
            l.setCreateTime(DateUtils.now());
        });

    }

    /**
     * 修改DTO转换为model实例
     *
     * @param dto 修改DTO
     * @return model实例
     */
    public static AbnProhibitAreas from(AbnProhibitAreasUpdateDTO dto) {
        return ModelDTOConverter.from(dto, AbnProhibitAreas.class, (AbnProhibitAreas l) -> {
            l.setUpdateTime(DateUtils.now());
        });
    }
}
